#include "CMap.h"

CONST BYTE CMap::_Map[_MapHeight][_MapWidth] = { 
	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
};

CMap::CMap() {
	BlackBrush = (HBRUSH)GetStockObject(BLACK_BRUSH);
	RedBrush = CreateSolidBrush(RGB(255, 0, 0));
}

CMap::~CMap() {
	DeleteObject(BlackBrush);
	DeleteObject(RedBrush);
}

VOID CMap::Render(CONST INT cxClient, CONST INT cyClient, HDC hdc) {
	HBRUSH OldBrush = (HBRUSH)SelectObject(hdc, RedBrush);

	for (INT h = 0; h < _MapHeight; h++) {
		for (INT w = 0; w < _MapWidth; ++w) {
			INT X = _Left + w * _Box32;
			INT Y = _Top + h * _Box32;
			if (_Map[h][w] == 1) {
				//draw the cell
				Rectangle(hdc, X, Y, X + _Box32, Y + _Box32);
			}
		}
	}

	SelectObject(hdc, OldBrush);
}
